import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


// funtor impl some interface as Listener
class BtnListener implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("Pressed");
    }
}


public class D14 {
    public static void main(String[] args) {
        Frame f = new Frame("Hello world");
        f.setLocation(500, 500);
        f.setSize(300, 200);
        f.setBackground(Color.MAGENTA);

        // add a button
        Button btn1 = new Button("Click Me");
        f.add(btn1);

        btn1.addActionListener(new BtnListener());

        f.setVisible(true);
    }
}